<?
class sql{
	var $con;

	function sql(){ 
		$this->con=mysql_pconnect(CFG_DBHOST,CFG_DBUSER,CFG_DBPASS);
		mysql_select_db(CFG_DBBASE,$this->con);
	}
	
	
	function request($req,$debug=0){
		if($debug) echo $req."<br />";
		$tmp=array();
		$res=mysql_query($req,$this->con);
		if(mysql_num_rows($res)>0){
			while($var=mysql_fetch_object($res)){
				$tmp[]=$var;
			}
		}
		return $tmp;
	}
	
	function request_single($req,$debug=0){
		if($debug) echo $req."<br />";
		$res=mysql_query($req,$this->con);
		if(mysql_num_rows($res)>0){
			$var=mysql_fetch_object($res);
			return $var;
		}else return false;
	}
	
	function query($req,$debug=0){
		if(is_array($req)){
			foreach($req as $r){
				if($debug) echo $r."<br />";
				mysql_unbuffered_query($r,$this->con) or die(mysql_error());			
			}
		}else{
			if($debug) echo $req."<br />";
			mysql_unbuffered_query($req,$this->con) or die(mysql_error());
		}
	}
	
}

?>